<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>客户信息管理</title>
    <link rel="stylesheet" href="/box/assets/css/style.css">
    <link rel="stylesheet" href="/box/assets/css/loader-style.css">
    <link rel="stylesheet" href="/box/assets/css/bootstrap.css">
    <link rel="stylesheet" href="/box/layui/css/layui.css">
    <script src="/box/js/jquery-3.3.1.js"></script>
    <script src="/box/layui/layui.js"></script>
    <script src="/box/js/config.js"></script>
    <link rel="shortcut icon" href="/box/assets/ico/minus.png">
    <style>
        .box-pad {
            padding: 1%
        }
        #edit, #contacts, #contactsEdit, #chat, #chatEdit, #order, #details {
            display: none;
            padding: 30px 50px 0 50px;
        }
        #contacts input, #chat input, #details input {
            border: none;
        }
    </style>
</head>

<body style="background: none">
    <!--  客户  -->
    <div id="edit">
        <form class="layui-form" lay-filter="cusEditForm" id="cusEditForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户编号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerId" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerName" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">地区：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="region" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户经理：</label>
                    <div class="layui-inline">
                        <select id="userId" name="userId">
                            <option value="-1">请选择</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户等级：</label>
                    <div class="layui-input-block">
                        <select id="customerLevel" name="customerLevel">
                            <option value="-1">请选择</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户满意度：</label>
                    <div class="layui-input-inline">
                        <select id="customerSatisfied" name="customerSatisfied">
                            <option value="-1">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户信用度：</label>
                    <div class="layui-input-inline">
                        <select id="customerCredit" name="customerCredit">
                            <option value="-1">请选择</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">地址：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="address" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">邮政编码：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="zipCode" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">电话：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="telephone" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">传真：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="fax" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">网址：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="website" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">营业执照注册号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="blrn" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">法人：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="legalPerson" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">注册资金（万元）：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="capital" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">年营业额：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="turnover" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">开户银行：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="bankDeposit" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">银行账号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="bankAccount" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">地税登记号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="landTax" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">国税登记号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="stateTax" class="layui-input">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!--  联系人  -->
    <div id="contacts">
        <form class="layui-form" id="contactsForm" style="margin-bottom: 30px" lay-filter="contactsForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户编号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerId" id="addCusId" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerName" class="layui-input" readonly>
                    </div>
                </div>
            </div>
        </form>
        <table class="layui-table" lay-filter="contactsTable" id="contactsTable"></table>
    </div>
    <div id="contactsEdit">
        <form class="layui-form" id="contactsEditForm" lay-filter="contactsEditForm">
            <input type="hidden" name="contactsId">
            <input type="hidden" name="customerId" id="customerId">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="contactsName" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">性别：</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="sex" value="0" title="男" checked>
                        <input type="radio" name="sex" value="1" title="女">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">职位：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="position" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">办公电话：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="workPhone" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">手机：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="phone" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">备注：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="remarks" class="layui-input">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!--  交往记录  -->
    <div id="chat">
        <form class="layui-form" id="chatForm" style="margin-bottom: 30px" lay-filter="chatForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户编号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerId" id="addChatId" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerName" class="layui-input" readonly>
                    </div>
                </div>
            </div>
        </form>
        <table class="layui-table" lay-filter="chatTable" id="chatTable"></table>
    </div>
    <div id="chatEdit">
        <form class="layui-form" id="chatEditForm" lay-filter="chatEditForm">
            <input type="hidden" name="chatId">
            <input type="hidden" name="customerId" id="chatCusId">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="chatTime" class="layui-input" id="chatDate" placeholder="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">地点：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="place" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">概要：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="outline" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">备注：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="remarks" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">详细信息：</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入详细信息" name="detailed" class="layui-textarea"></textarea>
                </div>
            </div>
        </form>
    </div>
    <!--  历史订单  -->
    <div id="order">
        <form class="layui-form" id="orderForm" style="margin-bottom: 30px" lay-filter="orderForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户编号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerId" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">客户名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="customerName" class="layui-input" readonly>
                    </div>
                </div>
            </div>
        </form>
        <table class="layui-table" lay-filter="orderTable" id="orderTable"></table>
    </div>
    <div id="details">
        <form class="layui-form" id="detailsForm" lay-filter="detailsForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">订单编号：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="orderNumber" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">日期：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="orderDate" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">送货地址：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="address" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">总金额：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="totalSum" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-block">
                    <input type="text" name="state" id="orderState" class="layui-input" readonly>
                </div>
            </div>
        </form>
        <table class="layui-table" lay-filter="detailsTable" id="detailsTable"></table>
    </div>
    <!--  主体  -->
    <div class="box-pad">
        <h1>客户信息管理</h1>
        <hr>
        <form class="layui-form" id="topForm" lay-filter="topForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户名：</label>
                    <div class="layui-inline">
                        <input type="text" id="customerName" class="layui-input" autocomplete="off">
                    </div>
                </div>
                <button type="button" class="layui-btn" style="margin-bottom: 10px" onclick="selects()">查询</button>
            </div>
        </form>
        <table class="layui-table" lay-filter="cusTable" id = "cusTable"></table>
        <script>
            function selects(){
                table.reload("cusTable",{
                    page: {
                        curr: 1
                    }
                    ,where: {
                        customerName : $("#customerName").val()
                    }
                });
            }
            var table;
            layui.use(['table','form','laydate'], function () {
                table = layui.table;
                var form = layui.form;
                var laydate = layui.laydate;

                $.get("http://localhost:8888/user/byRoleId", function (d) {
                    $.each(d.data,function () {
                        var options = $("<option></option>").appendTo("#userId");
                        options.text(this.userName).val(this.userId);
                    });
                });
                $.get("http://localhost:8888/dictionary/level", function (d) {
                    $.each(d.data,function () {
                        var options = $("<option></option>").appendTo("#customerLevel");
                        options.text(this.entry).val(this.name);
                    });
                });
                $.get("http://localhost:8888/dictionary/satisfied", function (d) {
                    $.each(d.data,function () {
                        var options = $("<option></option>").appendTo("#customerSatisfied");
                        options.text(this.entry).val(this.name);
                    });
                });
                $.get("http://localhost:8888/dictionary/credit", function (d) {
                    $.each(d.data,function () {
                        var options = $("<option></option>").appendTo("#customerCredit");
                        options.text(this.entry).val(this.name);
                    });
                });

                table.render({
                    elem: '#cusTable'
                    , url: 'http://localhost:8888/customer/list'
                    , text: {none: '没有查到相关数据'}
                    , even: true
                    , page: true
                    , limit: 10
                    , cols: [[
                        {field: 'customerId', title: '客户编号'}
                        , {field: 'customerName', title: '客户名称'}
                        , {field: 'customerLevel', title: '客户等级', templet: function (d) {
                                return d.eleDictionary.entry;
                            }
                        }
                        , {field: 'eleUser', title: '客户经理', templet: function (d) {
                                return d.eleUser.userName;
                            }
                        }
                        , {toolbar: '#barDemo', width: 200, title: '操作'}
                    ]]
                });

                //常规用法
                laydate.render({
                    elem: '#chatDate'
                });

                //  客户表内部按钮
                table.on('tool(cusTable)', function (obj) {
                    var data = obj.data;
                    var layEvent = obj.event;
                    if (layEvent === 'edit') {  // 编辑
                        layer.open({
                            type: 1,
                            title: "编辑客户信息",
                            //  皮肤
                            skin: "layui-layer-molv",
                            //  动画
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#edit"),
                            btn: ['确定','取消'],
                            success: function () {
                                form.val('cusEditForm',data);
                                $("#userId").val(data.userId);
                                $("#customerLevel").val(data.customerLevel);
                                $("#customerSatisfied").val(data.customerSatisfied);
                                $("#customerCredit").val(data.customerCredit);
                            },
                            yes : function () {
                                var str = $("#cusEditForm").serialize();
                                $.post(new Config().base_url + "/customer/update",str, function (das) {
                                    layer.close(layer.index);
                                    table.reload("cusTable");
                                });
                            }
                        });
                    } else if (layEvent === 'contacts') {  // 联系人
                        layer.open({
                            type: 1,
                            title: "联系人管理",
                            skin: "layui-layer-molv",
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#contacts"),
                            btn: ['确定'],
                            success: function () {
                                form.val('contactsForm',data);
                                table.render({
                                    elem: '#contactsTable'
                                    ,url:'http://localhost:8888/contacts/list?cusId=' + data.customerId
                                    ,text: {none: '没有查到相关数据'}
                                    ,even: true
                                    ,page : true
                                    ,limit : 10
                                    ,toolbar: "#contactsTopDemo"
                                    ,cols: [[
                                        {field:'contactsName', width: 90, title: '姓名'}
                                        ,{field:'sex', width: 60, title: '性别', templet : function (d) {
                                            return d.sex == 0 ? '男' : '女'
                                            }
                                        }
                                        ,{field:'position', width: 90, title: '职位'}
                                        ,{field:'workPhone', width: 130, title: '办公电话'}
                                        ,{field:'phone', width: 120, title: '手机'}
                                        ,{field:'remarks', title: '备注'}
                                        ,{toolbar:'#contactsDemo', width: 85, title: '操作'}
                                    ]]
                                });
                            }
                        });
                    } else if (layEvent === 'chats') { // 交往记录
                        layer.open({
                            type: 1,
                            title: "交往记录",
                            skin: "layui-layer-molv",
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#chat"),
                            btn: ['确定'],
                            success: function () {
                                form.val('chatForm',data);
                                table.render({
                                    elem: '#chatTable'
                                    ,url:'http://localhost:8888/chat/list?cusId=' + data.customerId
                                    ,text: {none: '没有查到相关数据'}
                                    ,even: true
                                    ,page : true
                                    ,limit : 10
                                    ,toolbar: "#chatTopDemo"
                                    ,cols: [[
                                        {field:'chatTime', width: 110, title: '时间'}
                                        ,{field:'place', width: 110, title: '地点'}
                                        ,{field:'outline', width: 140, title: '概要'}
                                        ,{field:'detailed', width: 133, title: '详细信息'}
                                        ,{field:'remarks', width: 115, title: '备注'}
                                        ,{toolbar:'#chatDemo', width: 85, title: '操作'}
                                    ]]
                                });
                            }
                        });
                    } else if (layEvent === 'orders') {   //  历史订单
                        layer.open({
                            type: 1,
                            title: "查看历史订单",
                            skin: "layui-layer-molv",
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#order"),
                            btn: ['确定'],
                            success: function () {
                                form.val('orderForm',data);
                                table.render({
                                    elem: '#orderTable'
                                    ,url:'http://localhost:8888/order/list?cusId=' + data.customerId
                                    ,text: {none: '没有查到相关数据'}
                                    ,even: true
                                    ,page : true
                                    ,limit : 10
                                    ,cols: [[
                                        {field:'orderNumber', width: 110, title: '订单编号'}
                                        ,{field:'orderDate', width: 120, title: '日期'}
                                        ,{field:'address', title: '送货地址'}
                                        ,{field:'eleDictionary', width: 75, title: '状态', templet : function (d) {
                                                return d.eleDictionary.entry;
                                            }
                                        }
                                        ,{toolbar:'#orderDemo', width: 60, title: '操作'}
                                    ]]
                                });
                            }
                        });
                    }
                });

                //  联系人表上面的工具栏
                table.on('toolbar(contactsTable)', function(obj){
                    switch(obj.event){
                        case 'conAdd':
                            layer.open({
                                type: 1,
                                title: "添加联系人信息",
                                //  皮肤
                                skin: "layui-layer-molv",
                                //  动画
                                anim: 0,
                                area: "800px",
                                maxmin: true,
                                content: $("#contactsEdit"),
                                btn: ['确定','取消'],
                                success: function () {
                                    $('#contactsEditForm')[0].reset();
                                    $("#customerId").val($("#addCusId").val());
                                },
                                yes: function () {
                                    var str = $("#contactsEditForm").serialize();
                                    $.post(new Config().base_url + "/contacts/add",str, function (das) {
                                        layer.close(layer.index);
                                        table.reload("contactsTable", {
                                            page : {
                                                curr : 1
                                            }
                                        });
                                    });
                                }
                            });
                            break;
                    }
                });
                //  联系人表内部的工具
                table.on('tool(contactsTable)', function (obj) {
                    var data = obj.data;
                    var layEvent = obj.event;
                    if (layEvent === 'delete') {
                        layer.confirm('真的要删除吗？', function (index) {
                            layer.close(index);
                            $.post("http://localhost:8888/contacts/delete", {conId : data.contactsId}, function (ds) {
                                table.reload("contactsTable", {
                                    page : {
                                        curr : 1
                                    }
                                });
                            });
                        })
                    } else if (layEvent === 'conEdit') {
                        layer.open({
                            type: 1,
                            title: "修改联系人信息",
                            //  皮肤
                            skin: "layui-layer-molv",
                            //  动画
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#contactsEdit"),
                            btn: ['确定','取消'],
                            success: function () {
                                form.val('contactsEditForm',data);
                                $("input[name=sex][value='0']").attr("checked", data.sex == 0 ? true : false);
                                $("input[name=sex][value='1']").attr("checked", data.sex == 1 ? true : false);
                                form.render("radio", "contactsEditForm");
                            },
                            yes: function () {
                                var str = $("#contactsEditForm").serialize();
                                $.post(new Config().base_url + "/contacts/update",str, function (das) {
                                    layer.close(layer.index);
                                    table.reload("contactsTable", {
                                        page : {
                                            curr : 1
                                        }
                                    });
                                });
                            }
                        });
                    }
                });

                //  交往记录表上面的工具栏
                table.on('toolbar(chatTable)', function(obj){
                    switch(obj.event){
                        case 'chatAdd':
                            layer.open({
                                type: 1,
                                title: "添加交往记录",
                                //  皮肤
                                skin: "layui-layer-molv",
                                //  动画
                                anim: 0,
                                area: "800px",
                                maxmin: true,
                                content: $("#chatEdit"),
                                btn: ['确定','取消'],
                                success: function () {
                                    $('#chatEditForm')[0].reset();
                                    $("#chatCusId").val($("#addChatId").val());
                                },
                                yes: function () {
                                    var str = $("#chatEditForm").serialize();
                                    $.post(new Config().base_url + "/chat/add",str, function (das) {
                                        layer.close(layer.index);
                                        table.reload("chatTable", {
                                            page : {
                                                curr : 1
                                            }
                                        });
                                    });
                                }
                            });
                            break;
                    }
                });
                //  交往记录表内部的工具
                table.on('tool(chatTable)', function (obj) {
                    var data = obj.data;
                    var layEvent = obj.event;
                    if (layEvent === 'chatDelete') {
                        layer.confirm('真的要删除吗？', function (index) {
                            layer.close(index);
                            $.post("http://localhost:8888/chat/delete", {chatId : data.chatId}, function (ds) {
                                table.reload("chatTable", {
                                    page : {
                                        curr : 1
                                    }
                                });
                            });
                        })
                    } else if (layEvent === 'chatEdit') {
                        layer.open({
                            type: 1,
                            title: "修改交往记录",
                            //  皮肤
                            skin: "layui-layer-molv",
                            //  动画
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#chatEdit"),
                            btn: ['确定','取消'],
                            success: function () {
                                form.val('chatEditForm',data);
                            },
                            yes: function () {
                                var str = $("#chatEditForm").serialize();
                                $.post(new Config().base_url + "/chat/update",str, function (das) {
                                    layer.close(layer.index);
                                    table.reload("chatTable", {
                                        page : {
                                            curr : 1
                                        }
                                    });
                                });
                            }
                        });
                    }
                });

                //  历史订单表内部的工具
                table.on('tool(orderTable)', function (obj) {
                    var data = obj.data;
                    var layEvent = obj.event;
                    if (layEvent === 'details') {
                        layer.open({
                            type: 1,
                            title: "历史订单详情",
                            //  皮肤
                            skin: "layui-layer-molv",
                            //  动画
                            anim: 0,
                            area: "800px",
                            maxmin: true,
                            content: $("#details"),
                            btn: ['返回'],
                            success: function () {
                                form.val('detailsForm',data);
                                $("#orderState").val(data.eleDictionary.entry);
                                table.render({
                                    elem: '#detailsTable'
                                    ,url:'http://localhost:8888/details/list?orderId=' + data.orderId
                                    ,text: {none: '没有查到相关数据'}
                                    ,even: true
                                    ,page : true
                                    ,limit : 10
                                    ,cols: [[
                                        {field:'eleGoods', title: '商品', templet : function (d) {
                                                return d.eleGoods.goodsName;
                                            }
                                        }
                                        ,{field:'number', width: 60, title: '数量'}
                                        ,{field:'eleGoods', width: 60, title: '单位', templet : function (d) {
                                                return d.eleGoods.company;
                                            }
                                        }
                                        ,{field:'eleGoods', width: 100, title: '单价', templet : function (d) {
                                                return d.eleGoods.money;
                                            }
                                        }
                                        ,{field:'total', width: 200, title: '总金额'}
                                    ]]
                                });
                            }
                        });
                    }
                });

            });
        </script>

        <!--  客户表按钮  -->
        <script type="text/html" id="barDemo">
            {{# var datas = JSON.parse(sessionStorage.getItem("login_user"));}}

            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'customer:update'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="edit" title="编辑"><span class="fontawesome-edit"></span></a>
            {{# } }}
            {{# });}}

            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'contacts:query'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="contacts" title="联系人"><span class="fontawesome-user"></span></a>
            {{# } }}
            {{# });}}

            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'chat:query'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="chats" title="交往记录"><span class="fontawesome-comments"></span></a>
            {{# } }}
            {{# });}}

            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'order:query'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="orders" title="历史订单"><span class="fontawesome-file"></span></a>
            {{# } }}
            {{# });}}
        </script>

        <!--  联系人表格上面的工具栏  -->
        <script type="text/html" id="contactsTopDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" lay-event="conAdd" title="添加"><span class="fontawesome-plus"></span></button>
            </div>
        </script>

        <!--  联系人表格内部的工具栏  -->
        <script type="text/html" id="contactsDemo">

            {{# var datas = JSON.parse(sessionStorage.getItem("login_user"));}}
            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'contacts:update'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="conEdit" title="修改"><span class="fontawesome-edit"></span></a>
            {{# } }}
            {{# });}}

            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'contacts:delete'){ }}
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete" title="删除"><span class="fontawesome-remove"></span></a>
            {{# } }}
            {{# });}}
        </script>

        <!--  交往记录表格上面的工具栏  -->
        <script type="text/html" id="chatTopDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" lay-event="chatAdd" title="添加"><span class="fontawesome-plus"></span></button>
            </div>
        </script>

        <!--  交往记录表格内部的工具栏  -->
        <script type="text/html" id="chatDemo">

            {{# var datas = JSON.parse(sessionStorage.getItem("login_user"));}}
            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'chat:update'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="chatEdit" title="修改"><span class="fontawesome-edit"></span></a>
            {{# } }}
            {{# });}}

            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'chat:delete'){ }}
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="chatDelete" title="删除"><span class="fontawesome-remove"></span></a>
            {{# } }}
            {{# });}}
        </script>

        <!--  历史订单表格内部的工具栏  -->
        <script type="text/html" id="orderDemo">
            {{# var datas = JSON.parse(sessionStorage.getItem("login_user"));}}
            {{# layui.each(datas.user_pers, function(index, item){ }}
            {{# if(item.percode == 'orderDetails:query'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="details" title="查看详情"><span class="fontawesome-file-alt"></span></a>
            {{# } }}
            {{# });}}
        </script>

    </div>
</body>
</html>